//
//  KKCollectionViewController.m
//  KKListViewDemo
//
//  Created by liaozhenming on 16/11/4.
//  Copyright © 2016年 liaozhenming. All rights reserved.
//

#import "KKCollectionViewController.h"

#import "UIViewController+List.h"

#import "TestCollectionViewCell.h"
#import "TestCollectionHeaderView.h"
#import "TestCollectionFooterView.h"

@interface KKCollectionViewController ()

@property (nonatomic, strong) NSMutableArray *arr_data;

@end

@implementation KKCollectionViewController


- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self kk_registerCollectionView: self.collectionView delegate: nil];
    [self.collectionView registerNib: [UINib nibWithNibName: @"TestCollectionViewCell" bundle: nil] forCellWithReuseIdentifier: @"TestCollectionViewCell"];
    
    [self.collectionView registerNib: [UINib nibWithNibName: @"TestCollectionHeaderView" bundle: nil] forSupplementaryViewOfKind: UICollectionElementKindSectionHeader withReuseIdentifier: @"TestCollectionHeaderView"];
    [self.collectionView registerNib: [UINib nibWithNibName: @"TestCollectionFooterView" bundle: nil] forSupplementaryViewOfKind: UICollectionElementKindSectionFooter withReuseIdentifier: @"TestCollectionFooterView"];
    
    [self private_initData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)private_initData {
    
    _arr_data = [NSMutableArray array];
    
    {
        KKListViewCellItem * cellItem1 = [KKListViewCellItem kk_cellItemWithKey: @"" cellSize:CGSizeMake(100, 120) cellClassName: NSStringFromClass([TestCollectionViewCell class])];
        KKListViewCellItem * cellItem2 = [KKListViewCellItem kk_cellItemWithKey: @"" cellSize:CGSizeMake(120, 150) cellClassName: NSStringFromClass([TestCollectionViewCell class])];
        KKListViewCellItem * cellItem3 = [KKListViewCellItem kk_cellItemWithKey: @"" cellSize:CGSizeMake(200, 240) cellClassName: NSStringFromClass([TestCollectionViewCell class])];
        
        KKListViewSectionItem *sectionItem = [KKListViewSectionItem kk_sectionItemWithKey: @"1" cellItems: @[cellItem1, cellItem2, cellItem3]];
        sectionItem.sectionHeaderSize = CGSizeMake(320, 120);
        sectionItem.sectionHeaderClassName = NSStringFromClass([TestCollectionHeaderView class]);
        sectionItem.sectionFooterSize = CGSizeMake(320, 80);
        sectionItem.sectionFooterClassName = NSStringFromClass([TestCollectionFooterView class]);
        [_arr_data addObject: sectionItem];
    }
    
    {
        KKListViewCellItem * cellItem1 = [KKListViewCellItem kk_cellItemWithKey: @"" cellSize:CGSizeMake(100, 120) cellClassName: NSStringFromClass([TestCollectionViewCell class])];
        KKListViewCellItem * cellItem2 = [KKListViewCellItem kk_cellItemWithKey: @"" cellSize:CGSizeMake(120, 150) cellClassName: NSStringFromClass([TestCollectionViewCell class])];
        KKListViewCellItem * cellItem3 = [KKListViewCellItem kk_cellItemWithKey: @"" cellSize:CGSizeMake(200, 240) cellClassName: NSStringFromClass([TestCollectionViewCell class])];
        
        KKListViewSectionItem *sectionItem = [KKListViewSectionItem kk_sectionItemWithKey: @"1" cellItems: @[cellItem1, cellItem2, cellItem3]];
        [_arr_data addObject: sectionItem];
    }
    
    [self setKk_sectionItems: _arr_data];
}

@end
